/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.guide.service;

import com.jeeplus.database.datasource.annotation.DS;
import com.jeeplus.modules.guide.entity.MobileAreaType;
import com.jeeplus.modules.guide.mapper.MatterAreaMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@DS("queuing")
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
@Slf4j
public class MobileAreaService {
    private final MatterAreaMapper matterAreaMapper;
    /**
     * 获取某点位详细信息
     *
     * @param orgrizeId
     * @return
     */
    public MobileAreaType selectAreaId(String orgrizeId){
        return matterAreaMapper.selectAreaId(orgrizeId);
    }

    /**
     * insertOrUpdateArea 新增点位信息
     *
     * @author azj
     * @version 2020-04-24
     */
    @Transactional(readOnly = false)
    public void insertOrUpdateArea(MobileAreaType mobileAreaType) {
        if(StringUtils.isNotBlank(mobileAreaType.getId())){
            matterAreaMapper.updateArea(mobileAreaType);
        }else{
            mobileAreaType.setId(UUID.randomUUID().toString());
            matterAreaMapper.insertArea(mobileAreaType);
        }
    }

    /**
     * delAreaId 删除某点位信息
     *
     * @author azj
     * @version 2020-04-24
     */
    @Transactional(readOnly = false)
    public void delAreaId(String id) {
        matterAreaMapper.delAreaId(id);
    }

    /**
     * selecCountAreaId 查询点位条数
     *
     * @author azj
     * @version 2020-04-24
     */
    public Integer selecCountAreaId(String orgrizeId){
        return matterAreaMapper.selecCountAreaId(orgrizeId);
    }
}
